package hlhj.fhp.checkpoint.customView

import android.content.Context
import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.widget.LinearLayout
import android.widget.PopupWindow
import android.widget.RelativeLayout
import hlhj.fhp.checkpoint.R
import hlhj.fhp.checkpoint.adp.ServentListAdp
import hlhj.fhp.checkpoint.javaBean.ServentBean
import kotlinx.android.synthetic.main.pop_server.view.*

/**
 * Created by Never Fear   on 2018\11\12 0012.
Never More....
 */
class ServerPop(private val c:Context) :PopupWindow() {
    private var serventAdp:ServentListAdp?=null
    private val datas=ArrayList<ServentBean.InfoBean>()

    init {

        this.height=RelativeLayout.LayoutParams.WRAP_CONTENT
        this.width=RelativeLayout.LayoutParams.WRAP_CONTENT
        this.isOutsideTouchable=true
        this.isFocusable=true
        this.animationStyle=R.style.rulePopStyle
        init()
    }

    private fun init() {
        contentView=LayoutInflater.from(c).inflate(R.layout.pop_server,null)
        serventAdp= ServentListAdp(datas)
        contentView.listView.layoutManager=LinearLayoutManager(c,LinearLayout.VERTICAL,false)
        contentView.listView.adapter=serventAdp

    }

    fun setDatas(data:ArrayList<ServentBean.InfoBean>){
        datas.clear()
        datas.addAll(data)
        serventAdp?.notifyDataSetChanged()
    }

}